//
//  CommentIndentTableViewCell.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/3/23.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "CommentIndentTableViewCell.h"
#import "PhotoSheetView.h"
#import "UICustomActionSheet.h"
#import "STActionSheet.h"
#import "DZNPhotoEditorViewController.h"
#import "UIImagePickerController+Edit.h"
@implementation CommentIndentTableViewCell

- (void)awakeFromNib {
    // Initialization code
    [self adaptiveViewLayout:self];
    self.textView.delegate = self;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)addPhoto:(id)sender {
    _addPhotoBlock(@"1");
}


- (IBAction)commentHandel:(UIButton *)sender {
    if (sender == _goodComment) {
        _goodComment.selected = YES;
        _middleComment.selected = NO;
        _badComment.selected = NO;
        _commentLevelBlock(@"1");
    }else if (sender == _middleComment) {
        _goodComment.selected = NO;
        _middleComment.selected = YES;
        _badComment.selected = NO;
        _commentLevelBlock(@"2");
    }else{
        _goodComment.selected = NO;
        _middleComment.selected = NO;
        _badComment.selected = YES;
        _commentLevelBlock(@"3");
    }
}



- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    
    _placeHolder.hidden = YES;
    
    return YES;
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
    if (_textView.text.length>0) {
        _placeHolder.hidden = YES;
    }else{
        _placeHolder.hidden = NO;
    }
    _addCommentBlock(_textView.text);
    return YES;
}
#pragma mark  调整自适应布局
- (void) adaptiveViewLayout:(UIView *)viewLayout{
    //视图自适应布局
    for (UIView *view in viewLayout.subviews) {
        view.frame = flexibleFrame(view.frame, NO);
        if ([view isKindOfClass:[UITextField class]]) {
            UITextField *viewField = (UITextField *)view;
            CGFloat fontSize = viewField.font.pointSize;
            viewField.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
        }else if ([view isKindOfClass:[UILabel class]]){
            UILabel *viewLabel = (UILabel *)view;
            CGFloat fontSize = viewLabel.font.pointSize;
            viewLabel.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
        }else if ([view isKindOfClass:[UIButton class]]){
            UIButton *viewButton = (UIButton *)view;
            CGFloat fontSize = viewButton.titleLabel.font.pointSize;
            viewButton.titleLabel.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
        }
        UIView *vv =view;
        for (UIView *view in vv.subviews) {
            view.frame = flexibleFrame(view.frame, NO);
            if ([view isKindOfClass:[UITextField class]]) {
                UITextField *viewField = (UITextField *)view;
                CGFloat fontSize = viewField.font.pointSize;
                viewField.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
            }else if ([view isKindOfClass:[UILabel class]]){
                UILabel *viewLabel = (UILabel *)view;
                CGFloat fontSize = viewLabel.font.pointSize;
                viewLabel.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
            }else if ([view isKindOfClass:[UIButton class]]){
                UIButton *viewButton = (UIButton *)view;
                CGFloat fontSize = viewButton.titleLabel.font.pointSize;
                viewButton.titleLabel.font = [UIFont systemFontOfSize:fontSize*VerticalTexeRatio()];
            }
            
        }
    }
}
@end
